*******************Table 7******************************
import delimited "FourPerson.csv", clear
egen subject=group(subjectid)
egen session=group(sessionid)

xtset subject

replace risk=-risk //normalizing based on experimental coding of variable
replace loss=-loss //normalizing based on experimental coding of variable

gen period=mod(decisionnumber,10)
replace period=10 if period==0

gen leader=0
replace leader=1 if mycurrentbest==currentbest

gen leaderboard=0
replace leaderboard=1 if treatment==2

gen lscore=leaderboard*currentbest

gen pscore=mycurrentbest
replace pscore=0 if treatment==2

**All
xtlogit decision leaderboard period  risk loss sunk grit compo acho extra agree neuro open cons, re vce(cluster session)

xtlogit decision pscore period risk loss sunk grit compo acho extra agree neuro open cons if treatment==1, re vce(cluster session)
xtlogit decision pscore period risk loss sunk grit compo acho extra agree neuro open cons if treatment==1 & leader==1 & currentbest>0, re vce(cluster session)
xtlogit decision pscore period risk loss sunk grit compo acho extra agree neuro open cons if treatment==1 & leader==0 & currentbest>0, re vce(cluster session)

xtlogit decision lscore period risk loss sunk grit compo acho extra agree neuro open cons if treatment==2, re vce(cluster session)
xtlogit decision lscore period risk loss sunk grit compo acho extra agree neuro open cons if treatment==2 & leader==1 & currentbest>0, re vce(cluster session)
xtlogit decision lscore period risk loss sunk grit compo acho extra agree neuro open cons if treatment==2 & leader==0 & currentbest>0, re vce(cluster session)

